package util;


public class Node {
	private Comparable data;
	private Node left;
	private Node right;
	
	public Node(Comparable data, Node left, Node right) {
		super();
		this.data = data;
		this.left = left;
		this.right = right;
	}

	public void addNode(Node newNode){
		int comp=newNode.data.compareTo(data);
		if(comp<0){
			if(left==null) left=newNode;
			else left.addNode(newNode);
		}
		if(comp>0){
			if(right==null) right=newNode;
			else right.addNode(newNode);
		}
	}

	public Comparable getData() {
		return data;
	}

	public void setData(Comparable data) {
		this.data = data;
	}

	public Node getLeft() {
		return left;
	}

	public void setLeft(Node left) {
		this.left = left;
	}

	public Node getRight() {
		return right;
	}

	public void setRight(Node right) {
		this.right = right;
	}
	
}
